home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / UPC12BS1.ZIP / LIB / MKMBOX.C < prev    next >
C/C++ Source or Header  |  1993-07-12  |  3KB  |  90 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    m k m b o x . c                                                 */
  3. /*--------------------------------------------------------------------*/
  4.  
  5. /*--------------------------------------------------------------------*/
  6. /*    Changes Copyright (c) 1990-1993 by Kendra Electronic            */
  7. /*    Wonderworks.                                                    */
  8. /*                                                                    */
  9. /*    All rights reserved except those explicitly granted by the      */
  10. /*    UUPC/extended license agreement.                                */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*                          RCS Information                           */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*
  18.  *    $Id: mkmbox.c 1.2 1993/07/13 01:13:32 ahd Exp $
  19.  *
  20.  *    Revision history:
  21.  *    $Log: mkmbox.c $
  22.  *     Revision 1.2  1993/07/13  01:13:32  ahd
  23.  *     Limit directory names for users to eight characters
  24.  *
  25.  *
  26.  *       21Nov1991 Break out of hlib.c                         ahd
  27.  */
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <time.h>
  33.  
  34. /*--------------------------------------------------------------------*/
  35. /*                    UUPC/extended include files                     */
  36. /*--------------------------------------------------------------------*/
  37.  
  38. #include "lib.h"
  39. #include "hlib.h"
  40.  
  41. /*--------------------------------------------------------------------*/
  42. /*                          Global variables                          */
  43. /*--------------------------------------------------------------------*/
  44.  
  45. currentfile();
  46.  
  47. /*--------------------------------------------------------------------*/
  48. /*    m k m a i l b o x                                               */
  49. /*                                                                    */
  50. /*    Build a mailbox name                                            */
  51. /*--------------------------------------------------------------------*/
  52.  
  53. char *mkmailbox(char *buf, const char *userid)
  54. {
  55.    boolean append = ( E_mailext != NULL );
  56.  
  57.    if (buf == NULL)           /* Do we need to allocate buffer?         */
  58.    {
  59.       buf = malloc( FILENAME_MAX );
  60.       checkref(buf);
  61.    } /* if */
  62.  
  63.    if (bflag[F_DIRECT])
  64.    {
  65.       sprintf(buf,"%s%c%.8s%c%s", E_maildir, SEPCHAR,
  66.                                userid, SEPCHAR,"newmail");
  67.    } /* if (bflag[F_DIRECT]) */
  68.    else {
  69.       char tuser[FILENAME_MAX];
  70.       strcpy( tuser, userid );
  71.  
  72.       if (strchr(userid, '.') == NULL )
  73.          tuser[8] = '\0';        /* Auto-truncate mbox name          */
  74.       else
  75.          append = FALSE;
  76.  
  77.       mkfilename(buf, E_maildir, tuser);
  78.    } /* else */
  79.  
  80. /*--------------------------------------------------------------------*/
  81. /*              If we need a mailbox extension, add one               */
  82. /*--------------------------------------------------------------------*/
  83.  
  84.    if ( append )
  85.       strcat( strcat(buf,".") , E_mailext );
  86.  
  87.    return buf;
  88.  
  89. } /* mkmailbox */
  90.